<?php

class Gamemaster extends CI_controller {

	function dashboard(){
		//check om man må være her (om man er gm)		
		$ingame = $this->session->userdata('ingame');
		$data['ingame'] = $ingame;
		if($ingame['ingame_id'] != 0){ //hvis man ikke er gm
			redirect('deltager/dashboard/'.$ingame['ingame_id']);
		}

		//modeller
		$this->load->model('core/kampagne');
		$this->load->model('translation/array_model');
		$this->load->model('rollespiller_model');
		//$this->load->model('kampagne_model');


		$data['overskrift_left'] = "Kampagnens PC'er";
		$data['overskrift_right'] = "Kampagnens sessioner";
		$data['content_left'] = array("gamemaster/pc_haandtering");
		$data['content_right'] = array("gamemaster/session_haandtering");

		$element = new kampagne();
		$element->find_kampagne($ingame['kampagne_id']);
		$data['kampagne'] = $element->kampagne;
		$element->find_alle_af_type('individ');
		$data['alle_individer'] = $element->alle_af_type; /* bruges i pc_haandterings-viewet */
		$element->find_hovedpersoner($ingame['kampagne_id']);
		$data['kampagne_hovedpersoner'] = $element->hovedpersoner;
		
		$element->find_sessions($ingame['kampagne_id']);
		$data['sessions'] = $element->sessions;

		$data['rollespillere'] = $this->rollespiller_model->find_rollespillere(1);

		if(!empty($data['sessions']))
		{
			$numItems = count($data['sessions']) -1;
			$data['naeste_session'] = $data['sessions'][$numItems];
		}
		else
		{
			$data['naeste_session'] = 0;
		}

		$this->load->view('includes/templates/bogpaapult', $data);
	}

}

?>
